﻿

<div style="height: 350px;overflow-y: auto;overflow-x: hidden;">
    <!--<input id="roleId" type="hidden" value="3">-->
    <ul id="system-auth-tree" class="ztree" style="padding: 20px 0px 20px 40px;"></ul>
</div>

<script>
    layui.use(['layer', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var admin = layui.admin;

        layer.load(2);
        var setting = {
            check: {enable: true,chkStyle: "radio",radioType: "all"},
            data: {
                simpleData: {enable: true}
            }
        };
        var json = admin.getTempData("system-auth-tree-json");
        if(json){
            var parentId= admin.getTempData("system-auth-parentId");
            var data = [];
            for(var i=0;i<json.length;i++){
                var isMenu = json[i]["isMenu"];
                if(isMenu == 1){
                    var a = {};
                    a.id = json[i].id;
                    a.name = json[i].name;
                    a.pId = json[i].parentId;
                    a.open= true;
                    if(parentId  && a.id == parentId){
                        a.checked = true;
                    }
                    data.push(a);
                }
            }
            data.push({id:"-1",name:"根节点",open:true})
            $.fn.zTree.init($('#system-auth-tree'), setting, data);
        }
        layer.closeAll('loading');

    });
</script>
